#ifndef _RAY_H
#define _RAY_H

#include <cassert>
#include <iostream>
using namespace std;

#include "../d_Math/d_Math.h"

using namespace d_Math;

// Ray class mostly copied from Peter Shirley and Keith Morley

// ====================================================================
// ====================================================================

class Ray {

public:

  // CONSTRUCTOR & DESTRUCTOR
  Ray (const d_Vec3f &orig, const d_Vec3f &dir) {
    origin = orig; 
    direction = dir; }
  Ray (const Ray& r) { 
    origin = r.origin;
    direction = r.direction; }

  // ACCESSORS
  const d_Vec3f& getOrigin() const { return origin; }
  const d_Vec3f& getDirection() const { return direction; }
  d_Vec3f pointAtParameter(float t) const {
    return origin+direction*t; }

private:
  Ray () { assert(0); } // don't use this constructor

  // REPRESENTATION
  d_Vec3f origin;
  d_Vec3f direction;

};

inline ostream &operator<<(ostream &os, const Ray &r) {
  os << "Ray <" <<r.getOrigin()<<", "<<r.getDirection()<<">";
  return os;
}

// ====================================================================
// ====================================================================

#endif
